home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Libraries / tcl7.4b3 / doc / case.n < prev    next >
Encoding:
Text File  |  1994-12-17  |  2.5 KB  |  60 lines

  1. '\"
  2. '\" Copyright (c) 1993 The Regents of the University of California.
  3. '\" Copyright (c) 1994 Sun Microsystems, Inc.
  4. '\"
  5. '\" See the file "license.terms" for information on usage and redistribution
  6. '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  7. '\" 
  8. '\" @(#) case.n 1.4 94/12/17 16:17:41
  9. '\" 
  10. .so man.macros
  11. .HS case tcl 7.0
  12. .BS
  13. '\" Note:  do not modify the .SH NAME line immediately below!
  14. .SH NAME
  15. case \- Evaluate one of several scripts, depending on a given value
  16. .SH SYNOPSIS
  17. \fBcase\fI string \fR?\fBin\fR? \fIpatList body \fR?\fIpatList body \fR...?
  18. .br
  19. \fBcase\fI string \fR?\fBin\fR? {\fIpatList body \fR?\fIpatList body \fR...?}
  20. .BE
  21.  
  22. .SH DESCRIPTION
  23. .PP
  24. \fINote: the \fBcase\fI command is obsolete and is supported only
  25. for backward compatibility.  At some point in the future it may be
  26. removed entirely.  You should use the \fBswitch\fI command instead.\fR
  27. .PP
  28. The \fBcase\fR command matches \fIstring\fR against each of
  29. the \fIpatList\fR arguments in order.
  30. Each \fIpatList\fR argument is a list of one or
  31. more patterns.  If any of these patterns matches \fIstring\fR then
  32. \fBcase\fR evaluates the following \fIbody\fR argument
  33. by passing it recursively to the Tcl interpreter and returns the result
  34. of that evaluation.
  35. Each \fIpatList\fR argument consists of a single
  36. pattern or list of patterns.  Each pattern may contain any of the wild-cards
  37. described under \fBstring match\fR.  If a \fIpatList\fR
  38. argument is \fBdefault\fR, the corresponding body will be evaluated
  39. if no \fIpatList\fR matches \fIstring\fR.  If no \fIpatList\fR argument
  40. matches \fIstring\fR and no default is given, then the \fBcase\fR
  41. command returns an empty string.
  42. .PP
  43. Two syntaxes are provided for the \fIpatList\fR and \fIbody\fR arguments.
  44. The first uses a separate argument for each of the patterns and commands;
  45. this form is convenient if substitutions are desired on some of the
  46. patterns or commands.
  47. The second form places all of the patterns and commands together into
  48. a single argument; the argument must have proper list structure, with
  49. the elements of the list being the patterns and commands.
  50. The second form makes it easy to construct multi-line case commands,
  51. since the braces around the whole list make it unnecessary to include a
  52. backslash at the end of each line.
  53. Since the \fIpatList\fR arguments are in braces in the second form,
  54. no command or variable substitutions are performed on them;  this makes
  55. the behavior of the second form different than the first form in some
  56. cases.
  57.  
  58. .SH KEYWORDS
  59. case, match, regular expression
  60.